appModule.component('nUploadPic', {
  templateUrl: 'components/meeting-home/upload-pictures/upload-pic.template.html',
  bindings: {
    actionImg: '<'
  },
  controller: [
    '$scope', 'FileUploader',
    function ($scope, FileUploader,) {
      var _this = this;
      var uploader = $scope.uploader = new FileUploader();
      uploader.onAfterAddingFile = function (fileItem) {

        $scope.file = (event.srcElement || event.target).files[0];
        if ($scope.file.size / 1024 < 5 * 1024) {

          var reader = new FileReader();

          reader.addEventListener('load', function (e) {
            //文件加载完之后，更新angular绑定
            $scope.$apply(function () {
              $scope.iconUrl = e.target.result;
              //console.log($scope.iconUrl);
              _this.actionImg($scope.iconUrl);
            });
          }, false);
          reader.readAsDataURL(fileItem._file);
        } else {
          layer.msg('上传图片大小不能超过5M');
        }
      }
    }
  ]
});



